var showInfoPanelContent = function(node){
	Ext.Ajax.request({
		url    : 'manager/getelement',
		params : {
		   node: node.id
		},
		success: function(response, opts) {
			var responseJson = Ext.decode(response.responseText);
			if (responseJson.success === "true") {				
				
				var IsCompany;
				var IsTur;
				var IsHotel;
				var IsTimes; 
				var IsRequest;
					
				if (node.id =='CompanyTreeRoot') IsCompany=true;
				if (node.id.match('Tur')) IsTur=true;
				if (node.id.match('Hotel')) IsHotel=true;
				if (node.id.match('Times')) IsTimes=true;
				if (node.id.match('Request')) IsRequest=true;

				if (IsCompany){
						var c_title = responseJson.title;
						var c_email = responseJson.email;
						var c_dateCreated = responseJson.dateCreated;					
				}else if (IsTur){
						var tur_title = responseJson.title;
						var tur_description=responseJson.description;
						var tur_dateCreated = responseJson.dateCreated;					
				}else if (IsTimes){
						var t_title = responseJson.title;
						var t_price = responseJson.price;
						var t_dateCreated = responseJson.dateCreated;
				}else if (IsHotel){
						var h_title = responseJson.title;
						var h_adress = responseJson.adress;
						var h_website = responseJson.website;
						var h_description = responseJson.description;
						var h_dateCreated = responseJson.dateCreated;
				}else {
						var r_title = responseJson.title;
						var r_company_name = responseJson.company_name; 
						var r_count_persons = responseJson.count_persons; 
						var r_name_tourist = responseJson.name_tourist; 
						var r_photo = responseJson.photo; 
						var r_phone_number = responseJson.phone_number; 
						var r_description = responseJson.description; 
						var r_birthDate = responseJson.birthDate; 					
				}					
							
							
	
				var infoCompanyTextAreaTitle = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoCompanyTitle',
					fieldLabel: 'Company name',
					value: c_title,
					anchor: '100%',
					editable: false,
					readOnly: true
				});

				var infoCompanyTextAreaEmail = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoCompanyEmail',
					fieldLabel: 'e-mail',
					value: c_email,
					anchor: '100%',
					editable: false,
					readOnly: true	
				});
					
				var infoCompanyDateCreatedField = new Ext.form.DateField({
					xtype: 'Datefield',
					id: 'infoCompanyDateCreated',
					fieldLabel: 'Date created',
					value: new Date(c_dateCreated),
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
					
				var infoTurTextAreaTitle = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoTurTitle',
					fieldLabel: 'Tour title',
					value: tur_title,
					anchor: '100%',
					editable: false,
					readOnly: true
				});	
						
				var infoTurTextAreaDescription=new Ext.form.TextArea({
					xtype:'textarea',
					height:155,
					id:'infoTurDescription',
					fieldLabel:'Description',
					value:tur_description,
					anchor:'100%',
					editable:false,
					readOnly:true							
				});
				
				var infoTurDateCreatedField = new Ext.form.DateField({
					xtype: 'Datefield',
					id: 'infoTurDateCreated',
					fieldLabel: 'Date created',
					value: new Date(tur_dateCreated),
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoHotelTextAreaTitle=new Ext.form.TextField({
					xtype: 'texfield',
					id:'infoHotelTitle',
					fieldLabel:'Hotel title',
					value: h_title,
					anchor:'100%',
					editable:false,
					readOnly:true							
				});
						
				var infoHotelTextAreaAdress=new Ext.form.TextField({
					xtype:'textfield',
					id:'infoHotelAdress',
					fieldLabel:'Adress',
					value:h_adress,
					anchor:'100%',
					editable:false,
					readOnly:true
				});
						
				var infoHotelTextAreaWebsite=new Ext.form.TextField({
					xtype:'textfield',
					id:'infoHotelWebsite',
					fieldLabel:'Website',
					value:h_website,
					anchor:'100%',
					editable:false,
					readOnl:true							
				});
				
				var infoHotelTextAreaDescription=new Ext.form.TextArea({
					xtype:'textarea',
					height:155,
					id:'infoHotelDescription',
					fieldLabel:'Description',
					value:h_description,
					anchor:'100%',
					editable:false,
					readOnly:true							
				});
						
				var infoHotelDateCreatedField = new Ext.form.DateField({
					xtype: 'Datefield',
					id: 'infoHotelDateCreated',
					fieldLabel: 'Date created',
					value: new Date(h_dateCreated),
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
					
				var infoTimesTextAreaTitle = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoTimesTitle',
					fieldLabel: 'Period',
					value: t_title,
					anchor: '100%',
					editable: false,
					readOnly: true
				});	
						
				var infoTimesTextAreaPrice = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoTimesPrice',
					fieldLabel: 'Price',
					value: t_price,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoTimesDateCreatedField = new Ext.form.DateField({
					xtype: 'Datefield',
					id: 'infoTimesDateCreated',
					fieldLabel: 'Date created',
					value: new Date(t_dateCreated),
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoRequestTextAreaTitle = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoRequestTitle',
					fieldLabel: 'Request title',
					value: r_title,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoRequestTextAreaCompanyName = new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoRequestCompanyName',
					fieldLabel: 'Company name',
					value: r_company_name,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoRequestTextAreaCountPersons = new Ext.form.NumberField({
					xtype: 'numberfield',
					id: 'infoRequestCountPersons',
					fieldLabel: 'Number of people',
					value: r_count_persons,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
					
				var infoRequestTextAreaNameTourist= new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoRequestNameTourist',
					fieldLabel: 'Name tourist',
					value: r_name_tourist,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
						
				var infoRequestTextPhoneNumber= new Ext.form.TextField({
					xtype: 'textfield',
					id: 'infoRequestPhoneNumber',
					fieldLabel: 'Phone number',
					value: r_phone_number,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
											
				var infoRequestTextDescription= new Ext.form.TextArea({
					xtype: 'textarea',
					id: 'infoRequestDescription',
					fieldLabel: 'Addition information',
					value: r_description,
					anchor: '100%',
					editable: false,
					readOnly: true		
				});					
					
				var infoRequestBirthDateField = new Ext.form.DateField({
					xtype: 'Datefield',
					id: 'infoRequestBirthDate',
					fieldLabel: 'Date of birthday',
					value: new Date(r_birthDate),
					anchor: '100%',
					editable: false,
					readOnly: true		
				});
					
				
				if (node.id =='CompanyTreeRoot'){
					var wTitle = "Info: Company"
					var aItems = [infoCompanyTextAreaTitle, infoCompanyTextAreaEmail, infoCompanyDateCreatedField];
					
					var companyInfoPanel = new Ext.FormPanel({
						id: 'companyInfoPanelId',
						labelWidth: 100,
						frame:true,
						title: wTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,							
						defaultType: 'textfield',
						items: aItems
					});	
		    	} else if (node.id .match('Tur')) {
					var wTitle = "Info: Tour"
					var aItems = [infoTurTextAreaTitle,infoTurTextAreaDescription,  infoTurDateCreatedField];
					
					var TurInfoPanel = new Ext.FormPanel({
						id: 'TurInfoPanelId',
						labelWidth: 100,
						frame:true,
						title: wTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,
						defaults: {width: 300},
						defaultType: 'textfield',
						items: aItems
					});						
				} else if (node.id.match('Hotel')) {
					var wTitle = "Info: Hotel"
					var aItems = [infoHotelTextAreaTitle, infoHotelTextAreaAdress,  infoHotelTextAreaWebsite,infoHotelTextAreaDescription,infoHotelDateCreatedField];
					
					var HotelInfoPanel = new Ext.FormPanel({
						id: 'HotelInfoPanelId',
						labelWidth: 100,
						frame:true,
						title: wTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,					
						defaultType: 'textfield',
						items: aItems
					});
				} else if (node.id.match('Times')) {
					var wTitle = "Info: Times"
					var aItems = [infoTimesTextAreaTitle, infoTimesTextAreaPrice,  infoTimesDateCreatedField];
					
					var TimesInfoPanel = new Ext.FormPanel({
						id: 'TimesInfoPanelId',
						labelWidth: 100,
						frame:true,
						title: wTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,
						defaultType: 'textfield',
						items: aItems
					});		
				} else{
					var paTitle = "Common Info: Request";
					var pbTitle = "Additional Info: Request";
					var paItems = [infoRequestTextAreaTitle,infoRequestTextAreaCompanyName, infoRequestTextAreaCountPersons,infoRequestTextAreaNameTourist];
					var pbItems = [infoRequestTextPhoneNumber, infoRequestTextDescription,infoRequestBirthDateField];
					
					var requestInfoForm1 = new Ext.FormPanel({
						id: 'requestInfoPanel1Id',
						labelWidth: 100,
						frame:true,
						title: paTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,					
						defaultType: 'textfield',					
						items: paItems
					});
					
					var requestInfoForm2 = new Ext.FormPanel({
						id: 'requestInfoPanel2Id',
						labelWidth: 100,
						frame:true,
						title: pbTitle,
						bodyStyle:'padding:5px 5px 0',
						width: 450,					
						defaultType: 'textfield',
						items: pbItems
					});
						
					var requestInfoPanel = new Ext.TabPanel({
						id: 'requestInfoPanelId',
						activeTab: 0,
						frame:true,
							items: [requestInfoForm1, requestInfoForm2]
					});				
				}
					
				
				var infopan = Ext.getCmp('infoPanelId'); /* Looks up an existing Component by id. Return object. 
											The Component, undefined if not found, or null if a Class was found.*/
					if (IsCompany){
						infopan.removeAll();
						infopan.add(companyInfoPanel);
						infopan.layout.setActiveItem('companyInfoPanelId');
					}
					else if(IsTur){
						infopan.removeAll();
						infopan.add(TurInfoPanel);
						infopan.layout.setActiveItem('TurInfoPanelId');						
					}
					else if(IsHotel){
						infopan.removeAll();
						infopan.add(HotelInfoPanel);
						infopan.layout.setActiveItem('HotelInfoPanelId');						
					}
					else if(IsTimes){
						infopan.removeAll();
						infopan.add(TimesInfoPanel);
						infopan.layout.setActiveItem('TimesInfoPanelId');						
					}
					else  {
						infopan.removeAll();
						infopan.add(requestInfoPanel);
						infopan.layout.setActiveItem('requestInfoPanelId');
					}				
			}
			else {
				Ext.Msg.alert('An error occured with the server.');
			}
		}
	});
};